#include "Complex.h"

Complex::Complex(double a, double b)
{
	this->a = a;
	this->b = b;
}

Complex::~Complex()
{

}

double Complex::getA()
{
	return a;
}

double Complex::getB()
{
	return b;
}

Complex Complex::operator + (const Complex& p)
{
	double na = a + p.a;
	double nb = b + p.b;
	Complex ret(na, nb);
	return ret;
}

Complex Complex::operator - (const Complex& p)
{
	double na = a - p.a;
	double nb = b - p.b;
	Complex ret(na, nb);
	return ret;
}

Complex Complex::operator * (const Complex& p)
{
	double na = a * p.a - b * p.b;
	double nb = b * p.a + a * p.b;
	Complex ret(na, nb);
	return ret;
}

Complex Complex::operator / (const Complex& p)
{
	double ntmp = p.a * p.a + p.b * p.b;
	double na = (a * p.a + b * p.b) / ntmp;
	double nb = (b * p.a - a * p.b) / ntmp;
	Complex ret(na, nb);
	return ret;
}

bool Complex::operator == (const Complex& p)
{
	return (this->a == p.a && this->b == p.b);
}

bool Complex::operator != (const Complex& p)
{
	return (!(*this == p));
}

Complex& Complex::operator = (const Complex& p)
{
	if (this != &p)
	{
		this->a = p.a;
		this->b = p.b;
	}

	return *this;
}

Complex& Complex::operator++ ()
{
	++a;
	++b;

	return *this;
}

Complex Complex::operator++ (int)
{
	Complex ret(a, b);
	++a;
	++b;
	return ret;
}

Complex& Complex::operator-- ()
{
	--a;
	--b;

	return *this;
}

Complex Complex::operator-- (int)
{
	Complex ret(a, b);
	--a;
	--b;
	return ret;
}